-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ProperEscapingFunction: fix overreach #668
Conversation
As part of the changes made in 624, the `T_COMMA` token was added to the list of tokens to skip over to allow for `echo` statements with multiple arguments passed as a coma-delimited list. As a side-effect, this caused the sniff to also examine `[s]printf()`-like function calls where the first parameter is a text string, while the second is often a variable within a call to one of the escaping functions. The current change fixes this by only adding the `T_COMMA` token to the "ignore when looking for the previous token"-list when in an `echo` statement. Includes unit test. Fixes 667 Additional notes: * I've run the sniff over WP Core to verify the fix and have verified that all 23 violations being throw up are correctly detected violations. * If it would be considered a good idea to also examine, `[s]printf()`-like function calls for this sniff for proper escaping, I suggest opening a separate, new feature request as that change would need significantly different and quite complex logic and does not fall within the scope of this bug fix.
It works much better but there are still false positives involving
See annotations in PR. |
Sorry, I was mistaken. Our code was using |
Thanks for testing @westonruter and glad to hear that this PR fixes the issue. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested and works great!
Hello, |
@manooweb Hi! This will be released with 2.3.1, which we are hoping to within the next few days. |
Ok 👍 thanks |
As part of the changes made in #624, the
T_COMMA
token was added to the list of tokens to skip over, to allow forecho
statements with multiple arguments passed as a coma-delimited list.As a side-effect, this caused the sniff to also examine
[s]printf()
-like function calls where the first parameter is a text string, while the second is often a variable within a call to one of the escaping functions.The current change fixes this by only adding the
T_COMMA
token to the "ignore when looking for the previous token"-list when in anecho
statement.Includes unit test.
Fixes #667
Additional notes:
[s]printf()
-like function calls for this sniff for proper escaping, I suggest opening a separate, new feature request as that change would need significantly different and quite complex logic and does not fall within the scope of this bug fix.